import type {
    KnowledgePage,
    KnowledgeParams,
    knowledgeResponseData,
    PageParams,
    doctorPageResponseData,
    ImageResponseData,
    FollowType,
    PartialConsult,
    depResponseData,
    ConsultOrderPreParams,
    consultOrderPreResponseData
} from '@/types/consult'
import { request } from '@/utils/request'
enum API {
    KNOWLEDGE_URL = "/patient/home/knowledge",
    DOCTORPAGE_URL = "/home/page/doc",
    FOLLOWDOCTOR_URL = "/like",
    ALLDEP_URL = "/dep/all",
    UPLOAD_URL = "/upload",
    ORDERPRE_URL = "/patient/consult/order/pre",
    ORDER_URL = "/patient/consult/order",
    PAY_URL = "/patient/consult/pay"

}
//获取健康知识列表
export const getKnowledgePage = (data: KnowledgeParams) => request.get<any, knowledgeResponseData>(API.KNOWLEDGE_URL, { data })
//获取关注医生列表
export const getDoctorPage = (params: PageParams) => request.get<any, doctorPageResponseData>(API.DOCTORPAGE_URL, { params })
//关注医生列表
export const followDoctor = (id: string, type: FollowType = 'doc') => request.post<any, any>(API.FOLLOWDOCTOR_URL, { id, type })
//获取所有科室
export const getAllDep = () => request.get<any, depResponseData>(API.ALLDEP_URL)
// 上传病情描述图片
export const uploadImage = (file: File) => {
    const fd = new FormData()
    // 说明：formData对象的key属性值后台定义
    fd.append('file', file)
    return request.post<any, ImageResponseData>(API.UPLOAD_URL, fd)
}

// 拉取预支付订单信息
export const getConsultOrderPre = (params: ConsultOrderPreParams) => request.get<any, consultOrderPreResponseData>(API.ORDERPRE_URL, { params })

// 生成订单
export const createConsultOrder = (data: PartialConsult) => request.post<any, any>(API.ORDER_URL, data)

// 获取支付地址  0 是微信  1 支付宝
export const getConsultOrderPayUrl = (data: {
    paymentMethod: 0 | 1
    orderId: string
    payCallback: string
}) => request.post<any, any>(API.PAY_URL, data)